package com.project.service.impl;


import com.project.bean.ClassRoomBean;
import com.project.mapper.IClassMapper;
import com.project.service.IClassService;

import java.time.LocalDate;
import java.util.List;

public class IClassServiceImpl extends BaseService implements IClassService {

    @Override
    public void add(ClassRoomBean classroom) {
        IClassMapper mapper =  session.getMapper(IClassMapper.class);
        mapper.add(classroom);
        this.commitAndClose();
    }

    @Override
    public boolean del(int id) {
        IClassMapper mapper =  session.getMapper(IClassMapper.class);
        try{
            mapper.del(id);
        } catch (Exception e){
            return false;
        }
        return false;
    }

    @Override
    public List<ClassRoomBean> findAll() {
        IClassMapper mapper =  session.getMapper(IClassMapper.class);
        List<ClassRoomBean> list = mapper.findAll();
        return list;
    }
    public static void main(String[] args){
        IClassService service = new IClassServiceImpl();
//        service.add(new ClassRoomBean("B栋","赵雪平", LocalDate.parse("2020-09-01")));
        System.out.println(service.findAll());
    }
}
